//
// Created by Jisam on 23/10/2024 22:08.
// Solution of  template
#include <bits/stdc++.h>

#define int long long
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define pb push_back
using namespace std;
const int MAXN = 2e5 + 5;
int c[MAXN], idx[MAXN];
vector<int> a[MAXN];
signed main()
{
    cin.tie(nullptr)->sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> c(n), idx(n, 0);

    for (int i = 0; i < n; i++)
        cin >> c[i];
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        a[c[i]].pb(x);
    }

    
    for (int i = 0; i < n; i++)
    {

        cout << a[c[i]][idx[c[i]]] << " ";
        // cout << idx[c[i]] << "\n";
        idx[c[i]]++;
    }
    return 0;
}